<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>修改商品</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/admin_style.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/table.css" />
<script type="text/javascript">
var APP = "__ROOT__";	
</script>
<script src="__STATIC__/js/jquery-1.7.2.min.js"></script>
	<script src="__PUBLIC__/js/addController.js"></script>
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <link href="__STATIC__/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>
       <!-- 配置文件 -->
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.min.js"></script>
    <style type="text/css"> 
   	.tab1{
   		display:none;
   	}
    .hiddenli{
    	position: relative;
    	top:-50px;
    	left:0px;
    	display: none;
    }
    .hiddenli span{
		width: 35px;
		padding: 2px;
		height: 40px;
		line-height: 40px;
		text-align: center;
		border: 1px solid #DDD;
		border-radius: 5px;
		float: left;
		background: #6595F5;
		cursor: pointer;
    }
   .hiddenli  .imgshow{
		width: 400px;
		height: 400px;
		background: none repeat scroll 0% 0% #FFF;
		border-radius: 5px;
		position: absolute;
		top: 50px;
		left: -1px;
		z-index: 1000;
		display: none;
    }
    .hiddenli  .imgshow .close{
    	height: 40px;
    	width: 40px;
    	background: #fff;
    	text-align: center;
    }
    .showGoosIMg li{
        list-style: none;
        float: left;
        width: 200px;
        height:200px;
        padding: 5px;
    }
    li{
        padding: 0px 10px;
        float: left;
        list-style: none;
    }
    li input{
        padding: 3px: 
    }
    .specValue{
        width: 600px;

    }
    .showGoosIMg li img{
        width: 200px;
        height: 200px;
        overflow: hidden;
    }
    .btn{
        display: inline-block;
        padding: 5px;
        background: #518CF1;
        color: #fff;
        cursor: pointer;
        text-align: center;
        border-radius: 5px;
        border:1px solid #ddd;
    }
    </style>
    <script type="text/javascript">
    $(function(){
            oldTid = $('select[name=pid]').val();
            oldSpec = $('.specValue').html();
            oldAttr = $('.attrValue').html();
        $('select[name=pid]').change(function(){

           tid = $(':selected').attr('tid');
           if(tid == oldTid){
             $('.specValue').html(oldSpec);
             $('.attrValue').html(oldAttr);
             return false;
           }
            $.ajax({
               type: "POST",
               url: "{|U:'getGoodsAttr'}",
               data: {tid:tid},
               dataType:'json',
               success: function(msg){
                    var attr = '';
                    var spec = '';
                    $.each(msg,function(k,v){
                        //==0属性 ==1 规格
                        if(v.attr_class == 0){
                            attr += "<li style='width:200px; heigh:50px;line-heigt:50px;inline-block;padding:5px 5px;'><input type='hidden' name='type_tid' value='"+v.type_tid+"' />"+v.attr_name+": <select name='attr[]' class='w200'><option value=''>选择属性</option>";
                                $.each(v.attrValue,function(kk,vv){
                                     attr += " <option value='"+v.aid+"|"+vv+"'>"+vv+"</option>";
                                });                       
                            attr += " </select></li>";
                        }else{
                           spec += "<li>"+v.attr_name+":<br/> ";
                                $.each(v.attrValue,function(kk,vv){
                                    spec += " <span class='attrtitle' style='width:180px;display:inline-block; heigh:50px;line-heigt:50px;'><input type='checkbox' value='"+v.aid+"|"+vv+"' name='spec[]'  />"+vv+"</span><span style='width:100px; heigh:50px;line-heigt:50px;inline-block;'>附加价格:<input type='text' name='specPric[]' class='w100'  /></span><br/>";
                                }); 
                                spec += " </li>";
                        }
                        
                    })
                    $('.attrValue').html(attr);
                    $('.specValue').html(spec);
               }
            });
        })
        //附加价格  规格
        $('.specValue input').live('click',function(event) {
                  s=$(this).index();
            if($('.specValue input').eq(s).attr('checked') == true){    
                   $('.specValue span').eq(s).html('<input type="text" name="goods_attr_value[]" class="w100"/>');
            }else if($(this).attr('checked') == false){
               
            }
        })
        

    })
    </script>
</head>
<body>
<body class="right_body">
	<div class="body">
		<div class="top_subnav">CMS内容管理平台 ＞ 修改商品</div>


		<div style="clear:both"></div>
		<div class="use_meth">
			<div class="title">
				<div class="title_info light">
					修改商品
				</div>
			</div>
<div class="wrap">
    <div class="hd-title-header">修改商品</div>
    <form action="" method="post" class="form-inline hd-form" enctype="multipart/form-data">
        <table class="hd-table hd-table-list">
           	
            <tr>
                <th class="w100">所属分类</th>
                <td> 
                    <select name="pid" class="w200 cateGoryChoose">
                        <option value="">选择分类</option>
                       <foreach from="$cateInfo" key="$k" value="$v">
                       <option value="{$v.cid}" tid ="{$v.type_tid}" <if value="$v['cid'] == $goodsData['category_cid']">selected="selected"</if> >{$v._name}</option>
                        </foreach>
                    </select>
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">所属品牌</th>
                <td>
                    <select name="bid" class="w200">
                        <option value="">选择品牌</option>
                       <foreach from="$brandInfo" key="$k" value="$v">
                            <option value="{$v.bid}" <if value="$v['bid'] == $goodsData['brand_bid']">selected="selected"</if> >{$v.brand_name}</option>
                        </foreach>
                    </select>
                </td>
             <td></td>
            </tr>
            <tr>
                <th class="w100">商品名称</th>
                <td  class="w100">
                    <input type="text" name="goods_name" class="w200" value="{$goodsData['goods_name']}"/> 
                </td>
                <td>商品名称长度 1 到 100 位</td>
            </tr>
           <tr>
                <th class="w100">商品副标题</th>
                <td  class="w100">
                    <input type="text" name="goods_hot_title" class="w200" value="{$goodsData['goods_hot_title']}"/> 
                </td>
                <td>商品热门推荐文字</td>
            </tr>
            <tr>
                <th class="w100">商品数量</th>
                <td>
                    <input type="text" name="goods_inventory" class="w200" value="{$goodsData['goods_inventory']}"/>
                </td>
                <td>  </td>
            </tr>
            <tr>
                <th class="w100">市场价格</th>
                <td>
                    <input type="text" name="goods_market" class="w200" value="{$goodsData['goods_market']}"/>
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">商城价格</th>
                <td>
                  <input type="text" name="goods_mall" class="w200" value="{$goodsData['goods_mall']}"/>
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">单位</th>
                <td>
                    <select name="goods_unit" class="w200">
                        <option value="">选择单位</option>
                      
                        <option value="个" <if value="$goodsData['goods_unit'] =='个'">selected="selected"</if>>个</option>
                            <option value="件" <if value="$goodsData['goods_unit'] =='件'">selected="selected"</if>>件</option>
                            <option value="条" <if value="$goodsData['goods_unit'] =='条'">selected="selected"</if>>条</option>
                            <option value="支" <if value="$goodsData['goods_unit'] =='支'">selected="selected"</if>>支</option>
                    </select>
                </td>
             <td></td>
            </tr>
           <tr>
                <th class="w100">商品属性</th>
                <td>
                 <div class="attrValue" width="650" >
                 <foreach from="$typeAttr" key="$k" value="$v">
                     <if value="$v.attr_class == 1"><?php continue; ?></if>
                    <li style='width:200px; heigh:50px;line-heigt:50px;inline-block;padding:5px 5px;'>
                    <input type='hidden' name='type_tid' value='{$v.type_tid}' />{$v.attr_name}
                     <select name='attr[]' class='w200'>
                         <option value=''>选择属性</option>
                    
                         <foreach from="$v.attrValue" key="$key" value="$val">              
                             <option value='{$v.aid}|{$val}' 
                             <foreach from="$GoodsAttrInfo" key="$goodskey" value="$goodsval">    
                             <if value="$val == $goodsval['goods_attr_value']">selected="selected"</if>
                        </foreach>
                            >{$val}</option>
                 </foreach>
                    
                 </select>
            </li>
               
            </foreach>
                </div>
                </td>
             <td></td>
            </tr>
          
           

           <tr>
            
           
                <th class="w100">商品规格</th>
                <td>
                    <div class="specValue" width="650">
<foreach from="$typeAttr" key="$k" value="$v">  
        <if value="$v.attr_class == 0">  <?php continue; ?></if>
    <li>{$v.attr_name}<br/> 
     <foreach from="$v.attrValue" key="$key" value="$val">
         <span class='attrtitle' style='width:180px;display:inline-block; heigh:50px;line-heigt:50px;'><input type='checkbox' value='{$v.aid}|{$val}' name='spec[]'  

         <foreach from="$GoodsAttrInfo" key="$goodskey" value="$goodsval">    
                    <if value="$val == $goodsval['goods_attr_value']">checked="checked"</if>
         </foreach>
                         />{$val}</span>
         <span style='width:100px; heigh:50px;line-heigt:50px;inline-block;'>附加价格:
         <input type='text' name='specPric[]' class='w100'
         <foreach from="$GoodsAttrInfo" key="$goodskey" value="$goodsval">    
                    <if value="$val == $goodsval['goods_attr_value']">value="{$goodsval.goods_attr_price}"</if>
         </foreach>
          />
         </span><br/>
    </foreach>    
     </li>
 </foreach>       
                 </div>
                </td>
                <td></td>
            </tr>
           <tr>
            
           
                <th class="w100">上传图像</th>
                <td class="uploadChoose">
					<input type="button" class="formUpload btn" value="表单上传" /><input type="button" class="ajaxUpload btn" value="无刷新上传" /> <span style=""> * 切换将清空已选择上传内容</span>
                </td>
                <td></td>
            </tr>
           
            <tr class="tab1">
                <th class="w100">表单上传</th>
                <td class='showGoosIMg' width="650">
                  <input type="file" name="goodsImg[]" />  
                </td>
                <td><span class="addInputFile btn">添加上传</span><span class="delInputFile btn">删除上传</span></td>
            </tr>
            
           
            <tr class="tab1">
                <th class="w100">无刷新上传</th>
                <td>
                  <div lab="uploadFile">
                <input id="listIMg" type="file" name="" multiple="true">
                <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
                <script type="text/javascript">
                    $(function() {
                        $('#listIMg').uploadify({
                            'formData'     : {//POST数据
                                '<?php echo session_name();?>' : '<?php echo session_id();?>',
                            },
                            'fileTypeDesc' : '上传文件',//上传描述
                            'fileTypeExts' : '*.jpg;*.png',
                            'swf'      : '__STATIC__/uploadify/uploadify.swf',
                            'uploader' : '{|U:"Admin/goods/uploadGoodsImg"}',
                            'buttonText':'选择文件',
                            'fileSizeLimit' : '2000KB',
                            'uploadLimit' : 1000,//上传文件数
                            'width':65,
                            // 'debug':true,
                            'height':25,
                            'successTimeout':10,//等待服务器响应时间
                            'removeTimeout' : 0.2,//成功显示时间
                            'onUploadSuccess' : function(file, data, response) {
                                data=$.parseJSON(data);
                                var imageUrl = data.image?data.url:'__STATIC__/image/default.png';
                                var li="<li path='"+data.path+"' url='"+data.url+"'><img src='"+imageUrl+"' class='hd-w80 hd-h70' /><div class='hiddenli'><span class='look'>查看</span><span class='del' >删除</span><span class='imgshow'><img /><span class='close'></span></span></div></li>";
                                $(".showGoosListIMg").prepend(li);
                                $('#inputHidden').append('<li>'+data.goods_info_smallIMg+'</li>');
                                //获取图片域值
                               var smallIMg =  $('#goods_info_smallIMg').val();
                               $('#goods_info_smallIMg').val(smallIMg+','+data.goods_info_smallIMg);
                            }
                        });
                    });
                </script>
                </td>
                <td>
                	
                </td>
            </tr>
            
            <tr>
                <th class="w100">列表图预览</th>
                <td class='showGoosListIMg' width="650">
                
<foreach from="$imgInfo" key="$k" value="$v"> 
<li>
    <img src='__ROOT__/upload/goods/middle/{$v}_thumb_400X400.jpg' class='hd-w80 hd-h70' />
    <div class='hiddenli'><span class='look'>查看</span><span class='del' >删除</span><span class='imgshow'><img />
        <span class='close'></span></span>
    </div></li>
</li>
</foreach>
              <!--隐藏表单 存放是上传缩略图文件名-->
            <input id="goods_info_smallIMg" type="hidden" name="goods_info_smallIMg" value="{$goodsData['goods_info_smallIMg']}" />
            <!--异步隐藏内容-->
                	<div id='inputHidden'  style="display: none;" >
                	<foreach from="$imgInfo" key="$k" value="$v"> 
                		<li>{$v}</li>
                	</foreach>
                	</div>
             <!--隐藏表单 存放是上传缩略图文件名-->
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">商品详情</th>
                <td>
                   <!-- 加载编辑器的容器 -->
    <script id="container" name="goods_info_detail" type="text/plain" style="width: 650px; z-index: 999;">
       {$goodsData['goods_info_detail']}
    </script>

    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
    </script>
                </td>
                <td>分类描述长度 1 到 255位  </td>
            </tr>

            <tr>
                <th class="w100">包装及参数</th>
                <td>
                   <!-- 加载编辑器的容器 -->
    <script id="container_sever" name="goods_info_sever" type="text/plain" style="width: 650px; z-index: 999;">
       {$goodsData['goods_info_sever']}
    </script>

    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container_sever');
    </script>
                </td>
                <td>分类描述长度 1 到 255位  </td>
            </tr>
            
        </table>
        <div class="position-bottom">
            <input type="submit" class="hd-btn hd-btn-success" value="修改"/>
        </div>
    </form>
</div>
		</div>
	
	</div>




</body>
</html>
